﻿import com.dinmax.isolution.*

class DoorGUI
extends MovieClip {
	
	private var device:Door;
	private var listener:WindowDeviceGUI;
	
	function DoorGUI(){
		if(this._parent._parent instanceof WindowDeviceGUI)	this.listener = WindowDeviceGUI(this._parent._parent);
		return;
	}
		
	public function getDevice():Door{
		return this.device;
	}
	public function setDevice(newDevice:Door):Void{
		this.device = newDevice;
		this.refresh();
		return;
	}
	
	public function setSelected(b:Boolean):Void {
		
		if(b){
			this.gotoAndStop(2);
			listener.showDeviceView(device);			
			
		} else {
			this.gotoAndStop(1);	
		}
		return;
	}
	
	public function getSelected():Boolean{
		return (this._currentframe == 2);
	}
	
	public function refresh():Void {
		this["txt_title"].text = this.device.getName();
		this["txt_group"].text = this.device.getGroup();
		if(this.device.getValue() == "on"){
			this["mcState"].gotoAndStop(1);
		} else {
			this["mcState"].gotoAndStop(2);
		}
						 
		return;
	}
	
	
}